package com.lizk.study.netty.day008;

import java.nio.IntBuffer;

/**
 * @author lizhikui
 * @date 2019/6/24 5:54
 */
public class BufferTest {
    public static void main(String[] args) {
        IntBuffer ib = IntBuffer.allocate(10);
        print(ib);

        ib.put(3);
        print(ib);

        ib.put(2);
        print(ib);
        ib.put(5);
        print(ib);

        ib.flip();
        print(ib);

        ib.get();
        print(ib);

        ib.get();
        print(ib);

        //ib.flip(); //limit => position
        ib.rewind(); //limit 不变
        print(ib);

        ib.clear();
        print(ib);

    }
    public static void print (IntBuffer ib){
        System.out.println("position:"+ib.position());
        System.out.println("limit:"+ib.limit());
        System.out.println("capacity:"+ib.capacity());
        System.out.println("------------");
    }
}
